package com.ruoyi.reward.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.reward.mapper.CommunityRewardMapper;
import com.ruoyi.reward.domain.CommunityReward;
import com.ruoyi.reward.service.ICommunityRewardService;

/**
 * 积分商品Service业务层处理
 * 
 * @author xianyu
 * @date 2025-04-04
 */
@Service
public class CommunityRewardServiceImpl implements ICommunityRewardService 
{
    @Autowired
    private CommunityRewardMapper communityRewardMapper;

    /**
     * 查询积分商品
     * 
     * @param id 积分商品主键
     * @return 积分商品
     */
    @Override
    public CommunityReward selectCommunityRewardById(Long id)
    {
        return communityRewardMapper.selectCommunityRewardById(id);
    }

    @Override
    public int reduceStock(Long rewardId, int num) {
        System.out.println("reduceStock: " + rewardId + " " + num);
        return communityRewardMapper.reduceStock(rewardId, num);
    }

    /**
     * 查询积分商品列表
     * 
     * @param communityReward 积分商品
     * @return 积分商品
     */
    @Override
    public List<CommunityReward> selectCommunityRewardList(CommunityReward communityReward)
    {
        return communityRewardMapper.selectCommunityRewardList(communityReward);
    }

    /**
     * 新增积分商品
     * 
     * @param communityReward 积分商品
     * @return 结果
     */
    @Override
    public int insertCommunityReward(CommunityReward communityReward)
    {
        return communityRewardMapper.insertCommunityReward(communityReward);
    }

    /**
     * 修改积分商品状态
     * 
     * @param communityReward 积分商品
     * @return 结果
     */
    @Override
    public int updateCommunityReward(CommunityReward communityReward)
    {
        return communityRewardMapper.updateCommunityReward(communityReward);
    }

    /**
     * 批量删除积分商品
     * 
     * @param ids 需要删除的积分商品主键
     * @return 结果
     */
    @Override
    public int deleteCommunityRewardByIds(Long[] ids)
    {
        return communityRewardMapper.deleteCommunityRewardByIds(ids);
    }

    /**
     * 删除积分商品信息
     * 
     * @param id 积分商品主键
     * @return 结果
     */
    @Override
    public int deleteCommunityRewardById(Long id)
    {
        return communityRewardMapper.deleteCommunityRewardById(id);
    }
}
